package com.bojiu.lawsearch.lawsearch.model;

import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import javax.persistence.Column;
import javax.persistence.Table;
import javax.persistence.Transient;
import javax.validation.constraints.NotNull;
import java.math.BigDecimal;
import java.util.Date;
import java.util.List;

/**
 * @author: afdiao
 * @Date：2020/4/5 15:05
 * @Description: 发布任务的实体类
 */
@Table(name = "mst_task")
@Data
@ApiModel(value = "任务对象",description = "用户发布的任务信息")
public class Task {

    @ApiModelProperty(value = "任务id",required = true)
    @Column(name = "id")
    private Integer id;

    @ApiModelProperty(value = "任务标题",required = true)
    @NotNull(message = "标题不能为空")
    @Column(name = "title")
    private String title;

    @ApiModelProperty(value = "任务标签",required = true)
    @NotNull(message = "问题分类不能为空")
    @Column(name = "labelId")
    private Integer labelId;

    @ApiModelProperty(value = "标签中文名",required = false)
    @Transient
    private String labelName;


    /**
     * 问题描述
     */
    @ApiModelProperty(value = "任务描述",required = true)
    @NotNull(message = "问题描述不能为空")
    @Column(name = "message")
    private String message;

    /**
     * 1 问答
     * 2 非问答
     */
    @ApiModelProperty(value = "任务类型1问答 2非问答",required = true)
    @NotNull(message = "任务类型不能为空")
    @Column(name = "type")
    private Integer type;

    /**
     * 微信支付的订单号，若发布任务时不需要支付则该字段为空
     */
    @ApiModelProperty(value = "发布任务涉及的账单金额，该字段可能为空",required = false)
    @Column(name = "orderNum")
    private String orderNum;

    /**
     * 需要微信支付的金额,不需要金额则为0
     */
    @ApiModelProperty(value = "任务支付的金额",required = false)
    @Column(name = "price")
    private Integer price;

    /**
     * 本次提问扣除的余额
     */
    @ApiModelProperty(value = "任务扣除的余额",required = false)
    @Column(name = "account")
    private Integer account;

    /**
     * 本次提问扣除的积分
     */
    @ApiModelProperty(value = "任务扣除的积分",required = false)
    @Column(name = "score")
    private Integer score;

    /**
     * 用户id
     */
    @ApiModelProperty(value = "发布任务的用户id",required = false)
    @Column(name = "userId")
    private Integer userId;

    /**
     * 用户昵称
     */
    @ApiModelProperty(value = "发布任务的用户昵称",required = false)
    @Transient
    private String userNickname;

    /**
     * 任务状态
     * 1.发布中,自动匹配，工程师抢单
     * 2.发布中，需要管理员指定工程师
     * 3.待支付，支付成功后随即发布任务
     * 4.任务已经有人接单，但是尚未完成
     * 5.任务已经完成等待用户确认
     * 6.任务已经完成
     */
    @ApiModelProperty(value = "任务状态，只有为1时该任务才能被抢单",required = false)
    @Column(name = "status")
    private Integer status;

    /**
     * 接单的工程师id
     */
    @ApiModelProperty(value = "接单任务的工程师id",required = false)
    @Column(name = "engineerId")
    private Integer engineerId;

    /**
     * 接单的工程师姓名
     */
    @ApiModelProperty(value = "接单任务的工程师姓名",required = false)
    @Transient
    private String engineerName;

    /**
     * 接单的工程师
     */
    @ApiModelProperty(value = "接单任务的工程师",required = false)
    @Transient
    private WechatUser engineerUser;

    @ApiModelProperty(value = "工程师的回答",required = false)
    @Column(name = "answer")
    public String answer;

    @Transient
    public WechatUser wechatUser;

    @ApiModelProperty(value = "工程师列表")
    public List<Engineer> engineerList;

    /**
     * 创建日期
     */
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    @ApiModelProperty(value = "创建日期")
    @Column(name = "addTime")
    private Date addTime;

    /**
     * 创建日期
     */
    @Transient
    private String expireTime;

    /**
     * 修改日期
     */
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    @ApiModelProperty(value = "修改日期")
    @Column(name = "updateTime")
    private Date updateTime;

    /**
     * 评分
     */
    @ApiModelProperty(value = "评分")
    @Column(name = "star")
    private BigDecimal star;
}
